package com.validator.demo;

import com.validator.plus.constraint.RangeEnum;
import lombok.Data;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
@Data
@ToString
public class Demo implements Serializable {

    private static final long serialVersionUID = 1019466745376831818L;
    @Length(min = 1, max = 5, message = "字段id长度在1到5个字符之间")
    private String id;

    @RangeEnum(allowableValues = {"M", "F"}, message = "字段sex允许取值为[M,F]")
    private String sex;

    @NotEmpty(message="用户名不能为空")
    @Length(min=6,max = 12,message="用户名长度必须位于6到12之间")
    private String userName;

    @NotEmpty(message="密码不能为空")
    @Length(min=6,message="密码长度不能小于6位")
    private String passWord;

    @Email(message="请输入正确的邮箱")
    private String email;

    @Pattern(regexp = "^(\\d{18,18}|\\d{15,15}|(\\d{17,17}[x|X]))$", message = "身份证格式错误")
    private String idCard;


}
